package swordRefersOffer.p61;

/**
 * @author: trtan
 * @create: 2021-04-10 19:36
 * @description:
 **/
public class Number {
    public static void main(String[] args) {
        int[] arr = new int[]{1,2,12,0,3};
        System.out.println(new Number().isStraight(arr));
    }

    public boolean isStraight(int[] nums) {
        int[] counts = new int[14];
        for (int i = 0; i < counts.length; i++) {
            counts[i] = 0;
        }
        for (int i = 0; i < nums.length; i++) {
            counts[nums[i]]++;
        }
        for (int i = 1; i <= counts.length - 5; i++) {
            int tmp = 0;
            for (int j = i; j < i + 5; j++) {
                if (counts[j] > 0) {
                    tmp++;
                }
            }
            if (tmp + counts[0] == 5) {
                return true;
            }
        }
        return false;
    }
}